//
//  HZJThreeTableViewController.swift
//  HZJNavigationView
//
//  Created by HZJ on 2017/2/20.
//  Copyright © 2017年 HZJ. All rights reserved.
//

import UIKit

class HZJThreeTableViewController: HZJBaseTabViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        myNavigationBar.backgroundColor = UIColor.brown
        tabView.frame = CGRect(x: 0, y: 0, width: SCREENW, height: SCREENH)
        
        myNavigationBar.myLeftBtn.setTitle("回去吧", for: UIControlState.normal)
        myNavigationBar.myLeftBtn.setBackgroundImage(UIImage(named: "1"), for: UIControlState.normal)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
//        print(scrollView.contentOffset.y)
        var s = (scrollView.contentOffset.y - 88) / 88
        if s >= 0 {
            s = 1
        }else if s > -1 && s < 0 {
            s = 1+s
        }else{
            s = 0
        }
        print("scrollView.contentOffset.y是\(scrollView.contentOffset.y + 20)")
        print("s是\(s)")
        if s > 0 && s <= 1 {
//            self.myNavigationBar.isTranslucent = false
        }else{
//            self.myNavigationBar.isTranslucent = true
        }
        let c = UIColor.red.withAlphaComponent(s)
//        self.myNavigationBar.barTintColor = c //没用
//        self.myNavigationBar.alpha = s //按钮会跟着变
        self.myNavigationBar.backgroundAlpha = s
        centerBtn.backgroundColor = c
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
